import { onMounted, onUnmounted, ref, watchEffect } from "vue";

export const useDate = () => {
  const date = ref("");
  const time = ref("");
  const nowDate = new Date();
  date.value =
    nowDate.getFullYear() +
    "-" +
    (nowDate.getMonth() + 1) +
    "-" +
    nowDate.getDate();
  const hour =
    nowDate.getHours() < 10 ? "0" + nowDate.getHours() : nowDate.getHours();
  const minutes =
    nowDate.getMinutes() < 10
      ? "0" + nowDate.getMinutes()
      : nowDate.getMinutes();
  const second =
    nowDate.getSeconds() < 10
      ? "0" + nowDate.getSeconds()
      : nowDate.getSeconds();
  time.value = hour + ":" + minutes + ":" + second;
  return { date, time };
};
